//
//  FSMenuTabCommon.m
//  cocoapodText
//
//  Created by apple on 16/8/13.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ShiPei.h"
#import "FSMenuTabCommon.h"
#import <Foundation/Foundation.h>

@implementation FSMenuTabCommon

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

-(instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor clearColor]];
        //添加子视图
        [self subView];
    }
    return self;
}

//子视图懒加载
-(void)subView{
    //文字
    UILabel *itemNameLabel=[[UILabel alloc]initWithFrame:[ShiPei CGRectMakeScale:0 :0 :0 :0]];
    [itemNameLabel setFont:[UIFont boldSystemFontOfSize:[ShiPei CGFloatMakeFontScaleWithPX:25]]];
    [itemNameLabel setTextAlignment:NSTextAlignmentCenter];
    [itemNameLabel setUserInteractionEnabled:YES];
    [itemNameLabel setBackgroundColor:[UIColor clearColor]];
    [self addSubview:itemNameLabel];
    self.itemNameLabel=itemNameLabel;
    //下划线
    UIImageView *itemUnderlineImage=[[UIImageView alloc]initWithFrame:[ShiPei CGRectMakeScale:0 :0 :0 :0]];
    [self addSubview:itemUnderlineImage];
    self.itemUnderlineImage=itemUnderlineImage;
}


-(void)setLabelText:(NSString *)labelText{
    [self.itemNameLabel setText:labelText];
    [self.itemNameLabel sizeToFit];
}

-(void)setFrame:(CGRect)frame{
    [super setFrame:frame];
    [self.itemNameLabel setCenter:[ShiPei CGPointMakeScale:frame.size.width/2 :frame.size.height/2]];
    [self.itemUnderlineImage setFrame:[ShiPei CGRectMakeScale:5 :frame.size.height-2 :frame.size.width-5 :2]];
}

@end